<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="text" id="phone">
    <button id="submit" onclick="search()">确定</button>
    <h1 id="result"></h1>

    <script type="text/javascript">
        function search() {
            // 1. 创建对象
            const xhr = new XMLHttpRequest();
            // 2. 初始化 设置类型（请求方式）与url
            xhr.open('POST', 'https://phoneonlinetime.api.bdymkt.com/phoneonlinetime');
            // 设置请求体内容的类型
            xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
            // 自定义头信息
            xhr.setRequestHeader('X-Bce-Signature', 'AppCode/a0ba26ef95924ff68054033c931172e1');
            // 3. 发送   设置请求参数（请求体）
            xhr.send(JSON.stringify({"transtype":"telinfo","productid":"online","mobile":"15607180997"}));
            // 4. 事件绑定
            xhr.onreadystatechange = function () {
                // 判断
                if (xhr.readyState === 4) {
                    if (xhr.status >= 200 && xhr.status < 300) {
                        // 处理服务端返回的结果
                        result.innerHTML = xhr.response;
                        console.log(xhr.response)
                    }
                }
            }

        }
    </script>
</body>

</html>